Python GTA V self driving car problem

by: cord, 7 years ago



import numpy as np
from PIL import ImageGrab
import cv2
import time

# just so this doesn't go on forever:

def screen_record():
    last_time = time.time()
    while(True):
        # 800x600 windowed mode
        printscreen =  np.array(ImageGrab.grab(bbox=(0,40,800,640)))
        print('loop took {} seconds'.format(time.time()-last_time))
        last_time = time.time()
        cv2.imshow('window',cv2.cvtColor(printscreen, cv2.COLOR_BGR2RGB))
        if cv2.waitKey(25) & 0xFF == ord('q'):
            cv2.destroyAllWindows()
            break
            
screen_record()


So its not refreshing 1 window, its creating infinite amount of windows in a window.
I couldnt find any help, please help!




You must be logged in to post. Please login or register an account.



Hmm, I really do not know, good looks fine to me at a quick glance, and I went ahead and copy and pasted it for myself and it works fine for me.

What version of Python are you using? Operating system?

-Harrison 7 years ago

You must be logged in to post. Please login or register an account.


Im using windows 7 and python 3.6
my windows however isnt genuine so maybe thats the problem!

-cord 7 years ago

You must be logged in to post. Please login or register an account.


That is highly unlikely to be the issue, but I dunno what it would be either.

-Harrison 7 years ago

You must be logged in to post. Please login or register an account.


Well I guess the universe just doesnt want me to make a self driving car in beam.ng :(

-cord 7 years ago

You must be logged in to post. Please login or register an account.